package com.ygqh.baby.utils;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

import com.ygqh.baby.model.DrawPrize;
import com.ygqh.baby.model.PrizeItem;
import com.ygqh.baby.model.PrizeItemRule;

public class InitPrizeItemRule {
	private static List<PrizeItemRule> list60 = null;
	private static List<PrizeItemRule> list34 = null;
	private static List<PrizeItemRule> list5 = null;
	private static List<PrizeItemRule> list1 = null;
	static {

		list60 = new ArrayList<PrizeItemRule>();
		list34 = new ArrayList<PrizeItemRule>();
		list5 = new ArrayList<PrizeItemRule>();
		list1 = new ArrayList<PrizeItemRule>();
		
		BigDecimal b01 = new BigDecimal("0.10");
		BigDecimal b06 = new BigDecimal("0.60");
		BigDecimal b07 = new BigDecimal("0.70");
		BigDecimal b08 = new BigDecimal("0.80");
		BigDecimal b09 = new BigDecimal("0.90");
		BigDecimal b10 = new BigDecimal("1");

		PrizeItemRule ruleA1 = new PrizeItemRule(0, 1, 3, b06, b06);
		PrizeItemRule ruleA2 = new PrizeItemRule(0, 4, 7, b07, b01);
		PrizeItemRule ruleA3 = new PrizeItemRule(0, 8, 15, b08, b01);
		PrizeItemRule ruleA4 = new PrizeItemRule(0, 16, 25, b09, b01);
		PrizeItemRule ruleA5 = new PrizeItemRule(0, 26, 33, b10, b01);

		PrizeItemRule ruleB1 = new PrizeItemRule(0, 1, 3, b06, b06);
		PrizeItemRule ruleB2 = new PrizeItemRule(0, 4, 5, b07, b01);
		PrizeItemRule ruleB3 = new PrizeItemRule(0, 6, 9, b08, b01);
		PrizeItemRule ruleB4 = new PrizeItemRule(0, 10, 15, b09, b01);
		PrizeItemRule ruleB5 = new PrizeItemRule(0, 16, 23, b10, b01);

		PrizeItemRule ruleC1 = new PrizeItemRule(0, 1, 3, b06, b06);
		PrizeItemRule ruleC2 = new PrizeItemRule(0, 4, 4, b07, b01);
		PrizeItemRule ruleC3 = new PrizeItemRule(0, 5, 6, b08, b01);
		PrizeItemRule ruleC4 = new PrizeItemRule(0, 7, 9, b09, b01);
		PrizeItemRule ruleC5 = new PrizeItemRule(0, 10, 13, b10, b01);

		PrizeItemRule ruleD1 = new PrizeItemRule(0, 1, 3, b06, b06);
		PrizeItemRule ruleD2 = new PrizeItemRule(0, 4, 4, b07, b01);
		PrizeItemRule ruleD3 = new PrizeItemRule(0, 5, 5, b08, b01);
		PrizeItemRule ruleD4 = new PrizeItemRule(0, 6, 6, b09, b01);
		PrizeItemRule ruleD5 = new PrizeItemRule(0, 7, 8, b10, b01);

		list60.add(ruleA1);
		list60.add(ruleA2);
		list60.add(ruleA3);
		list60.add(ruleA4);
		list60.add(ruleA5);

		list34.add(ruleB1);
		list34.add(ruleB2);
		list34.add(ruleB3);
		list34.add(ruleB4);
		list34.add(ruleB5);

		list5.add(ruleC1);
		list5.add(ruleC2);
		list5.add(ruleC3);
		list5.add(ruleC4);
		list5.add(ruleC5);

		list1.add(ruleD1);
		list1.add(ruleD2);
		list1.add(ruleD3);
		list1.add(ruleD4);
		list1.add(ruleD5);
	}

	public static DrawPrize getRuleList(DrawPrize drawPrize) {
		LinkedList<PrizeItem> prizeItems = drawPrize.getPrizeItems();
		for (PrizeItem item : prizeItems) {
			if (item.getRate().compareTo(new BigDecimal("0.60")) ==0) {
				item.setRuleList(list60);
			} else if (item.getRate().compareTo(new BigDecimal("0.34")) ==0) {
				item.setRuleList(list34);

			} else if (item.getRate().compareTo(new BigDecimal("0.05")) ==0) {
				item.setRuleList(list5);

			} else {
				item.setRuleList(list1);

			}
		}
		return drawPrize;
	}

}
